//
//  SAStatisticsManagementCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/7/22.
//

#import "SAStatisticsManagementCell.h"
#import "SAStatisticsManagementModel.h"

@interface SAStatisticsManagementCell ()

@property (nonatomic, strong) UILabel *numLab;
@property (nonatomic, strong) UILabel *priceLab;

@property (nonatomic, strong) UILabel *returnNumLab;
@property (nonatomic, strong) UILabel *returnPriceLab;

@end

@implementation SAStatisticsManagementCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SAStatisticsManagementModel *)model {
    _model = model;
    self.numLab.text = [NSString stringWithFormat:@"销售数:%@",model.saleCount];
    self.priceLab.text = [NSString stringWithFormat:@"销售额:%0.2lf",[model.salePrice doubleValue]/100.f];
    
    self.returnNumLab.text = [NSString stringWithFormat:@"退货数:%@",model.returnCount];
    self.returnPriceLab.text = [NSString stringWithFormat:@"退货额:%0.2lf",[model.returnPrice doubleValue]/100.f];
}

-(void)initUI {
    self.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.numLab];
    [self.contentView addSubview:self.priceLab];
    [self.contentView addSubview:self.returnNumLab];
    [self.contentView addSubview:self.returnPriceLab];
}

-(UILabel *)numLab {
    if (!_numLab) {
        _numLab = [[UILabel alloc] initWithFrame:SARectMake(120, 0, 100, 20)];
        _numLab.textColor = kLightgGrayColor;
        _numLab.font = kFont(15);
        _numLab.textAlignment = NSTextAlignmentLeft;
    }
    return _numLab;
}

-(UILabel *)priceLab {
    if (!_priceLab) {
        _priceLab = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(225), 0, kScaleNum(150), kScaleNum(20))];
        _priceLab.textColor = kLightgGrayColor;
        _priceLab.font = kFont(15);
        _priceLab.textAlignment = NSTextAlignmentLeft;
    }
    return _priceLab;
}

-(UILabel *)returnNumLab {
    if (!_returnNumLab) {
        _returnNumLab = [[UILabel alloc] initWithFrame:SARectMake(120, 25, 100, 20)];
        _returnNumLab.textColor = kLightgGrayColor;
        _returnNumLab.font = kFont(15);
        _returnNumLab.textAlignment = NSTextAlignmentLeft;
    }
    return _returnNumLab;
}

-(UILabel *)returnPriceLab {
    if (!_returnPriceLab) {
        _returnPriceLab = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(225), kScaleNum(25), kScaleNum(150), kScaleNum(20))];
        _returnPriceLab.textColor = kLightgGrayColor;
        _returnPriceLab.font = kFont(15);
        _returnPriceLab.textAlignment = NSTextAlignmentLeft;
    }
    return _returnPriceLab;
}

@end
